<template>
  <div class="header">
    <h1>我是Header</h1>
    <p>Count的值是{{ count }}</p>
    <p>价格是{{ price }}</p>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  name: "Header",
  mounted() {
    console.log(this);
    //查看mapState方法返回的对象
    // console.log(mapState(["count", "price"]));
    // console.log(mapState({ count1: "count", price1: "price" }));
    // console.log(mapState(["count", "price"]).count.call(this));
  },
  computed: {
    //直接使用mapState去获取store中的值,并且提供了计算属性给我们,我们展开放在computed中
    ...mapState(["count", "price"]),
    /* count() {
      return this.$store.state.count;
    },
    price() {
      return this.$store.state.price;
    }, */
  },
};
</script>

<style scoped>
.header {
  margin: 30px;
  background: yellowgreen;
}
</style>